package com.demo.day1

class Foo {
    fun bar(str: String, lon: Long): Unit {
        println("str:$str,lon:$lon")
    }
}

// 无返回
fun foo(): Unit {
    println("foo")
}

// 返回字符串
fun foo(p0: Int): String {
    return p0.toString()
}

// 接收一个方法作为变量
fun getMethod(p: (Foo, String, Long) -> Any) {
    p(Foo(), "abc", 123L)
}

// 接收参数定义默认值

fun defaultParam(x: Int = 5, y: String = "abc"): Unit {
    println("X:$x->Y:$y")
}

// 接收参数定义默认值

fun defaultParam(x: Int = 5, y: String = "abc", z: Long = 3L): Unit {
    println("X:$x->Y:$y->Z:$z")
}

// 返回多个参数
fun multiParam(): Triple<Int, String, Double> {
    return Triple(123, "Triple", 32.0)
}

fun main(vararg args: String) {
    println(args.contentToString())
    val fb = Foo::bar
    getMethod(fb)
    val fo: () -> Unit = ::foo
    val forent: (Int) -> String = ::foo
    fo()
    val reS: String = forent(123)
    println(reS)

    val df: (Int, String) -> Unit = ::defaultParam

    defaultParam(4, "bbc")
    defaultParam(4, "bbc", 5L)
    defaultParam(y = "nb", z = 12L, x = 15)

    val (a, b, c) = multiParam()

    println("a:$a,b:$b,c:$c,a+c:${a + c}")
}